﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Net;
using System.Net.NetworkInformation;
using Domain.Entities;

namespace Domain.NetworkService
{
    public class EchoResult : NetworkTestResult
    {
        public long Rtt {get;set;}
        new public IPStatus Status { get; set; }
        public override string ToString()
        {
            return String.Format("{0} {1} {2} {3} {4}", VarDateTime, NetworkTestDescription.ECHO, IP, Status, Rtt);
        }
        public override string ToString(ToStringFormatArgs formatArg)
        {
            if (formatArg.Equals(ToStringFormatArgs.CommonSurvey))
            {
                return String.Format("{0} {1} {2} {3} {4}", VarDateTime,
                                                NetworkTestDescription.ECHO,
                                                IP,
                                                Status == IPStatus.Success?"Успешно выполнен. ":"Ошибка: "+Status,
                                                Status == IPStatus.Success?"Время приема-передачи: "+ Rtt + "мс.":"");
            }

            return ToString();
        }
        public override void WriteToDB(string name)
        {
            DBWorker dbw = new DBWorker();

            dbw.WriteTestResult(this, name);
        }
    }

}
